#include <iostream>
#include <vector>
using namespace std;

const int NMAX = 100;

vector<int> a[NMAX];
int n;
int vis[100];
int cnt;

void init()
{ int m;
  cin >> n >> m;
  
  for(int i=0; i<m; i++)
  { int u,v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
}

void dfs(int u)
{ vis[u]=1;
  cout << u << " ";
  
  int k=a[u].size();
  for(int i=0; i<k; i++)
  { int v = a[u][i];
    if(vis[v]==0)
      dfs(v);
  }
  
}

int main()
{ init();
 
  for(int u=1; u<=n; u++)
    vis[u]=0;
    
  int u=4;  
  vis[u]=1;
 
  cnt=0;
  for(int v=1; v<=n; v++)
    if(vis[v]==0) 
    { cnt++; 
      dfs(v);
      cout << endl;
    }
  cout << cnt << " subtrees with root " << u << endl;    
  
                 
  return 0;
}
